package com.twu.biblioteca;

import java.util.Vector;

public class BooksLibrary extends Library<Book> {

    public BooksLibrary() {
        loadItems();
    }

    @Override
    protected void loadItems() {
        items.add(new Book("Head First Java"));
        items.add(new Book("Design Patterns"));
        items.add(new Book("Refactoring Code"));
        items.add(new Book("Atlas Shrugged"));
        items.add(new Book("The Kite Runner"));
    }

    @Override
    public Vector<String> getAllItemDetails() {
        Vector<String> bookTitles=new Vector<String>();
        for(int i=0;i< items.size();i++)
            bookTitles.add(items.elementAt(i).getTitle());
        return bookTitles;

    }

    public boolean reserveBook(int bid){

        if(items.get(bid-1).getStatus()==BookStatus.AVAIL){
            items.get(bid - 1).toggleStatus();
            System.out.println("Thank You!Enjoy the book.");
            return true;
        }

        else{
            System.out.println("Sorry we don't have the book yet.");
            return false;
        }
    }
}
